<?php
/**
 * @name /themes/default/framework.php
 * @author Michael Foss <mfoss@clarionsafety.com>
 * @version 2007.07.02
 *
 * This is the default framework.
 */

ReqLib('/themes/PageParams.php');
ReqLib('/lib/public/HTML.php');

/**
 * Framework class.
 *
 */
class Framework {
  /**
   * Page parameters.
   *
   * @var PageParams
   */
  var $PageParams;

  /**
   * Constructor.
   *
   * @return Framework
   */
  function Framework() {
    $this->PageParams = new PageParams();
    if (function_exists(DefineParams))
      DefineParams($this->PageParams);
  }

  /**
   * Builds the page contents, top to bottom.
   *
   */
  function BuildPage() {
    if (function_exists(DefinePreload))
      DefinePreload();
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
<?
    HTML::JS(_webroot('/js/jquery-1.5.1.min.js'));
    HTML::JS(_webroot('/js/jquery-ui-1.8.11.custom.min.js'));
    HTML::CSS(_webroot('/css/jquery-ui-1.8.11.custom.css'));
    HTML::JS(_webroot('/js/jquery.dataTables.min.js'));
    HTML::CSS(_webroot('/css/data-tables.css'));
    HTML::CSS(_webroot('/css/selectlist.css'));
    HTML::JS(_webroot('/js/jquery.selectlist.pack.js'));
    HTML::CSS(_webroot('/media/css/TableTools_JUI.css'));
    HTML::JS(_webroot('/media/js/ZeroClipboard.js'));
    HTML::JS(_webroot('/media/js/TableTools.min.js'));
?>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<link rel="stylesheet" type="text/css" href="<?=_webroot('/css/style.css') ?>" />
  <link rel="shortcut icon" href="<?=_webroot('/images/favicon.png') ?>" />
<?
    if ($this->PageParams->Title && $this->PageParams->PostTitle) {
?>    <title><?=htmlspecialchars($this->PageParams->Title) ?> - <?=htmlspecialchars($this->PageParams->PostTitle) ?></title>
<?
    }
    elseif ($this->PageParams->PostTitle) {
?>    <title><?=htmlspecialchars($this->PageParams->PostTitle) ?></title>
<?
    }
    elseif ($this->PageParams->Title) {
?>    <title><?=htmlspecialchars($this->PageParams->Title) ?></title>
<?
    }
    else {
      global $Config;
?>    <title><?=htmlspecialchars($Config->SiteName) ?></title>
<?
    }
    if (function_exists(DefineHeader))
      DefineHeader();
    if ($this->Description) {
?>    <meta name="Description" content="<?=htmlspecialchars($this->Description) ?>">
<?
    }
    if (is_array($this->PageParams->Keywords) && count($this->PageParams->Keywords)) {
?>    <meta name="Keywords" content="<?
      for ($i = 0; $i < count($this->PageParams->Keywords); $i++)
        echo ($i ? ',' : '') . $this->PageParams->Keywords[$i];
?>">
<?
    }
?>  </head>
  <body>
    <div id="Body">
      <a id="Logo" href="<?=_webroot('/index.php') ?>"><img src="<?=_webroot('/images/logo.gif') ?>" alt="Logo" /></a>
<?
    if (function_exists(DefineContent))
      DefineContent();
    $links = array(
      'index.php' => 'Home',
      'about.php' => 'About Us',
      'give.php' => 'Ways to Give',
      'news.php' => 'News & Events',
      'faq.php' => 'FAQ',
      '[[LOGIN]]' => '[[LOGIN]]',
      'gallery.php' => 'Photo Gallery',
      'contact.php' => 'Contact Us',
    );
?>
    </div> <!-- /Body -->
    <div id="footer_wrapper">
      <div id="footer">
        <div id="bottom_navigation">
<?
    foreach ($links as $link => $text) {
      if ($link == '[[LOGIN]]') {
        if (!$_SESSION['userId']) {
          $link = 'login_register.php';
          $text = 'Login/Register';
        }
        else {
          $link = 'logout.php';
          $text = 'Logout';
        }
      }
      println(($text == 'Home' ? '' : ' | ') . '<a href="' . _webroot('/' . $link) . '">' . htmlspecialchars($text) . '</a>');
    }
?>
        </div>
        <div id="copy">
          Copyright &copy;<?=date('Y') ?>. All rights reserved. Design by SKM
        </div>
        <div id="footer_bg"></div>
      </div>
    </div> <!-- /footer_wrapper -->
  </body>
</html>
<?
  }
}